﻿@model IEnumerable<Vizzio.Models.IngresoDeProducto>

@{
    ViewBag.Title = "Busqueda de importaciones";
}

<h2>Busqueda de Ingresos de Productos</h2>
<form class="form-inline" method="post" action="/IngresoDeProducto/Buscar" role="form">
    <div class="form-group">
        <div class='input-group date' id='datetimepicker8'>
            <span class="input-group-addon"><i class="glyphicon glyphicon-th"></i></span>
            <input type='text' id="FechaInicial" name="FechaInicial" class="form-control" readonly placeholder="Fecha Inicial"/>
        </div>
    </div>
    <div class="form-group">
        <div class='input-group date' id='datetimepicker9'>
            <span class="input-group-addon"><i class="glyphicon glyphicon-th"></i></span>
            <input type='text' id="FechaFinal" name="FechaFinal" class="form-control" readonly placeholder="Fecha Final" />
        </div>
    </div>
    <button type="submit" class="btn btn-primary btn-sm"><span class="glyphicon glyphicon-search"></span> Buscar</button>
</form>
<p>
    @Html.ActionLink("Registrar Ingreso", "Create")
</p>
<table class="table">
    <tr>        
        <th>
            @Html.DisplayNameFor(model => model.CodigoDeIngresoDeProducto)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Concepto)

        </th>
        <th>
            @Html.DisplayNameFor(model => model.Fecha)
        </th>
       
        <th>
            @Html.DisplayNameFor(model => model.CostoTotal)

        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.CodigoDeIngresoDeProducto)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Concepto)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Fecha)
        </td>
        <td>
            @item.getCostoTotal()
        </td>
        <td>
            @Html.ActionLink("Ver Detalle", "Details", new { id = item.IngresoDeProductoID })
            @if (item.Concepto == "Importacion")
            {
                <span>
                    |@Html.ActionLink("Gastos de importacion", "Index", "GastosDeImportacion", new { id = item.IngresoDeProductoID }, null)
                </span>
            } 
            @if (item.FechaRecibida == null && item.Concepto!="InventarioInicial")
            {
                <span>
                    |@Html.ActionLink("Recepcionar Productos", "VerRecepcionar", new { id = item.IngresoDeProductoID })
                </span>
            }
            @if (item.FechaRecibida == null && item.Concepto != "InventarioInicial")
            {
                <span>
                    @*| @Html.ActionLink("Editar", "Edit", new { id = item.IngresoDeProductoID })*@
                    @*| @Html.ActionLink("Eliminar", "Delete", new { id = item.IngresoDeProductoID })*@
                </span>
            }       
        </td>
    </tr>
}

</table>

@section Scripts {

    <script type="text/javascript">
        
            $('#datetimepicker8.input-group.date').datepicker({
                format: "dd/mm/yyyy",
                weekStart: 1,
                language: "es",
                autoclose: true
            });

            $('#datetimepicker9.input-group.date').datepicker({
                format: "dd/mm/yyyy",
                weekStart: 1,
                language: "es",
                autoclose: true
            });
            $("#datetimepicker8.input-group.date").on("dp.change", function (e) {
                $('#datetimepicker9').data("DateTimePicker").setMinDate(e.date);
            });
            $("#datetimepicker9.input-group.date").on("dp.change", function (e) {
                $('#datetimepicker8').data("DateTimePicker").setMaxDate(e.date);
            });


    </script>

}

